<%--
    Document   : error
    Created on : Jun 6, 2014, 4:34:44 AM
    Author     : Yogesh Paisode
--%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<%

        String copyfirstName=(String)session.getAttribute("copyfirstName");
        String copylastName=(String)session.getAttribute("copylastName");
        String id=(String)session.getAttribute("id");
        String activationCode=(String)session.getAttribute("activationCode");
        String message="";

        if(copyfirstName==null){
                message="User ";
                session.setAttribute("message","MyPostedAd");
                String  url[]=request.getRequestURI().split("/");
                String pageRedir=url[2];
                session.setAttribute("pageRedir",pageRedir);
                response.sendRedirect("login.jsp");

            }
        else{
                message=copyfirstName.substring(0,1).toUpperCase()+copyfirstName.substring(1);
                out.print("<title>"+copyfirstName.substring(0,1).toUpperCase()+copyfirstName.substring(1)+"-My Advertisement</title>");
            }

%>
<jsp:include page="header.jsp"/>
<jsp:include page="startUpWith.jsp"/>
 <!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.gradienttable {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #999999;
	border-collapse: collapse;
}
table.gradienttable th {
	padding: 0px;
	background: #d5e3e4;
	background: url();
	background: -moz-linear-gradient(top,  #d5e3e4 0%, #ccdee0 40%, #b3c8cc 100%);
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d5e3e4), color-stop(40%,#ccdee0), color-stop(100%,#b3c8cc));
	background: -webkit-linear-gradient(top,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
	background: -o-linear-gradient(top,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
	background: -ms-linear-gradient(top,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
	background: linear-gradient(to bottom,  #d5e3e4 0%,#ccdee0 40%,#b3c8cc 100%);
	border: 1px solid #999999;
}
table.gradienttable td {
	padding: 0px;
	background: #ebecda;
	background: url();
	background: -moz-linear-gradient(top,  #ebecda 0%, #e0e0c6 40%, #ceceb7 100%);
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ebecda), color-stop(40%,#e0e0c6), color-stop(100%,#ceceb7));
	background: -webkit-linear-gradient(top,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
	background: -o-linear-gradient(top,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
	background: -ms-linear-gradient(top,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
	background: linear-gradient(to bottom,  #ebecda 0%,#e0e0c6 40%,#ceceb7 100%);
	border: 1px solid #999999;
}
table.gradienttable th p{
	margin:0px;
	padding:8px;
	border-top: 1px solid #eefafc;
	border-bottom:0px;
	border-left: 1px solid #eefafc;
	border-right:0px;
}
table.gradienttable td p{
	margin:0px;
	padding:8px;
	border-top: 1px solid #fcfdec;
	border-bottom:0px;
	border-left: 1px solid #fcfdec;;
	border-right:0px;
}
</style>

 <script type="text/javascript">
     // Popup window code
     function newPopup(url) {
         popupWindow = window.open(
		url, 'popUpWindow', 'height=600,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
     }
</script>


<%

        


        if(copyfirstName==null){
                message="User ";

            }
        else{
              message=copyfirstName.substring(0,1).toUpperCase()+copyfirstName.substring(1);
            }

        org.hibernate.SessionFactory sessionFactory=com.Auto.Common.PostAd.Hibernate.PostAd_HibernateUtil.getSessionFactory();
        org.hibernate.Session openSession=sessionFactory.openSession();
        org.hibernate.Transaction transaction=openSession.beginTransaction();

        org.hibernate.Query query=openSession.createQuery("from com.Auto.Common.PostAd.Hibernate.Postad where idFromUserInformation='"+id+"'");
        java.util.List l=query.list();



        String idFromUserInformation="";
        String postAd_Company_Name="";
        String postAd_Address="";
        String postAd_Location="";
        String postAd_Mobile_Number="";
        String postAd_Landline_Number="";
        String postAd_Image_Size="";
        String postAd_Templet_Image="";
        String postAd_Ad_Id="";
        String postAd_AmountToBePaid="";
        String postAd_Ad_Apprval="";





%>

<div style="position:relative;width: auto;z-index: 10000;">
    <div id="cssmenu" style="background-color: black;">
     <section class="innerpages">
         <div class="grid_12" style="background-image: url('commonfiles/images/satyapal.jpg'); width:100%;">
             <h1><%
             out.print(message+" Your Advertisement State Is Here..");
            %> </h1>
         </div>
     </section>
</div>
</div>
<div class="block2">
  <div class="container_12">
    <!--==============================content================================-->
    <section class="content">
      <div class="wrapper">
        <article class="grid_12 last-col"><br><br><br>
          <div class="hello_box">


          
<a href="postAd.jsp"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTosXA1Z-zpEjEASsNMYLPRjLn6vvTjMHjY7NuusaPS9xCR_Tgf2o9CYlQ"/></a>
<%
                int i=0;

                if(l.isEmpty()){

                     out.print("<br>You Have Not Apply For Any Advertisement <br><a href=\"postAd.jsp\">Click Hear To Apply For Advertisement</a>");
                 }else{

                    out.print("<table class=\"gradienttable\"><tr><th><p>Index</p></th><th><p>Post Id</p></th><th><p>Company Name</p></th><th><p>Company Address</p></th><th><p>Location</p></th><th><p>Mobile Number</p></th><th><p>Landlinne Number</p></th><th><p>Post Size</p></th><th><p>Image</p></th><th><p>Advertisement Status</p></th><th><p>Amount And Pay</p></th><!--th><p>Scan And Pay</p></th--></tr>");
               for(Object o:l){

                        i=i+1;

                        com.Auto.Common.PostAd.Hibernate.Postad postad=(com.Auto.Common.PostAd.Hibernate.Postad)o;

                        idFromUserInformation=postad.getIdFromUserInformation();
                        postAd_Company_Name=postad.getPostAdCompanyName();
                        postAd_Address=postad.getPostAdAddress();
                        postAd_Location=postad.getPostAdLocation();
                        postAd_Mobile_Number=postad.getPostAdMobileNumber();
                        postAd_Landline_Number=postad.getPostAdLandlineNumber();
                        postAd_Image_Size=postad.getPostAdImageSize();
                        postAd_Templet_Image=postad.getPostAdTempletImage();
                        postAd_Ad_Id=postad.getPostAdAdId();
                        postAd_AmountToBePaid=postad.getPostAdAmountToBePaid();
                        postAd_Ad_Apprval=postad.getPostAdAdApprval();
                       

                        String img="";
                        String button="",button2="";


                         if(postAd_Ad_Apprval.equals("0")){
                                    img="";
                                    postAd_AmountToBePaid="Waiting For Approval";
                                    button="";
                                    
                         }
                        else{
                                    img="";
                                    button="<br><script async=\"async\" src=\"https://www.paypalobjects.com/js/external/paypal-button.min.js?merchant=rahul.paisode@gmail.com\" data-button=\"buynow\" data-name=\"PostAd\" data-callback=\"http://localhost:8084/Auto7.1/MyPostedAd.jsp\" data-env=\"sandbox\"></script>";
                                   // button2="<td><script async=\"async\" src=\"https://www.paypalobjects.com/js/external/paypal-button.min.js?merchant=yogesh.paisode@gmail.com\" data-button=\"qr\" data-name=\"Advertisement\" data-callback=\"http://localhost:8084/Auto7.1/MyPostedAd.jsp\" data-env=\"sandbox\"></script></td>";
                        }



                        java.io.BufferedReader br = null;

		try {

			String sCurrentLine;

			br = new java.io.BufferedReader(new java.io.FileReader("VehicleHai/"+activationCode+"/PostAdvertisement/"+postAd_Ad_Id+".vhi"));
                        postAd_Templet_Image="";
			while ((sCurrentLine = br.readLine()) != null) {
				//System.out.println(sCurrentLine);
                                postAd_Templet_Image=postAd_Templet_Image+sCurrentLine;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

                        out.print("<tr><td><p>"+i+"</p></td><td><p>"+postAd_Ad_Id+"</p></td><td><p>"+postAd_Company_Name+"</p></td><td><p>"+postAd_Address+"</p></td>");
                        out.print("<td><p>"+postAd_Location+"</p></td><td><p>"+postAd_Mobile_Number+"</p></td><td><p>"+postAd_Landline_Number+"</p></td>");
                        out.print("<td><p>"+postAd_Image_Size+"</p></td><td><a  href=\"JavaScript:newPopup('"+postAd_Templet_Image+"');\"><p><img src='"+postAd_Templet_Image+"' width=30 height=10/></p></a></td>");
                        out.print("<td><p><img src='"+img+"' width=100 height=90/></p></td><td><p>"+postAd_AmountToBePaid+"/-"+button+"</p></td></tr>");
                       // out.print(button2);
                        out.print("");

                 }

               }


%>



</table>






          </div>
        </article>
      </div>
      <div class="wrapper projects">
        <div class="row clearfix">


        </div>
      </div>
    </section>
  </div>
</div>


<jsp:include page="footer.jsp"/>
